package cn.edu.sjzc;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;




public class TcpServer {
public static ArrayList<Socket> socketList= new ArrayList<Socket>();
	/**
	 *
	 * @param args
	 *X!!
	 *2013-7-30
	 */
	public static void main(String[] args) {
	try {
		int serverPort=2345;
		int clientCount = 0;
		ServerSocket server=new ServerSocket(serverPort);
		while(true){
			if (socketList.size()<2){
				Socket clientSocket = server.accept();
				socketList.add(clientSocket);
				new Thread(new ServerThread(clientSocket,clientCount)).start();
				clientCount++;
			}
			else{
				server.close();
			}
		}
	}catch(IOException e){
		
	}

	}

}
